home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 050a / clist_28.zip / CALLLIST.S < prev    next >
Text File  |  1993-03-26  |  14KB  |  193 lines

  1. /****************************************************************************
  2.  *   FILENAME:  C:\TSE\MAC\CALLLIST.S V2.8 (FOR TSE 1.0)                    *
  3.  *   AUTHOR  :  "Buddy" E. Ray Asbury, Jr.                                  *
  4.  *   DATE    :  Fri 03-26-1993 12:27:52                                     *
  5.  *                                                                          *
  6.  *  CallList is designed for SAL application developers to use as an        *
  7.  *  analysis tool.  It generates a listing file which includes each         *
  8.  *  procedure AND MENU within the SAL file, showing                         *
  9.  *                                                                          *
  10.  *      ■ the commands called AND occurrence counts                         *
  11.  *      ■ the other procedures called AND occurrence counts                 *
  12.  *      ■ seperates calls according to the arguments when possible (see     *
  13.  *          modifications lists below for v2.0)                             *
  14.  *      ■ optionally shows the code AND stack sizes for procedures          *
  15.  *      ■ summary of the commands & procedures information for the          *
  16.  *        entire file                                                       *
  17.  *                                                                          *
  18.  *  These features can be helpful WHEN optimizing applications.             *
  19.  *                                                                          *
  20.  *  Since operation of CallList depends upon detecting "words", the WordSet *
  21.  *  must be correctly.  For example, IF your default WordSet does NOT       *
  22.  *  INCLUDE "~", but you use that character in procedure names, CallList    *
  23.  *  must be aware of that in order to function correctly.  In the main      *
  24.  *  function below, simply edit the first SetGlobalInt line for             *
  25.  *  "gCL_WordSet" so that it includes such characters.  At the least,       *
  26.  *  gCL_WordSet should INCLUDE "0..9A..Za..z".  After making this change,   *
  27.  *  IF needed, be sure to recompile this file.  Then, simply place          *
  28.  *  CALLLIST.MAC & CALLLST2.MAC in either                                   *
  29.  *                                                                          *
  30.  *      1.  the current directory                                           *
  31.  *      2.  the directory "pointed" to by MACPATH                           *
  32.  *      3.  the startup directory of The SemWare Editor                     *
  33.  *                                                                          *
  34.  *  Then, start the editor with the file to be analyzed, AND execute        *
  35.  *  CallList.  The SAL file (.S), which must be the current file, is        *
  36.  *  copied to a temporary buffer AND the Copy is used by CallList.  The     *
  37.  *  original SAL file is NOT modified.  During processing, messages will    *
  38.  *  appear to show what CallList is doing.  ON large files, CallList may    *
  39.  *  take several minutes.                                                   *
  40.  *                                                                          *
  41.  *  Here is a sample listing:                                               *
  42.  *                                                                          *
  43.  *      INTEGER PROC mFactor()                                              *
  44.  *        Return()                  Count:    1                             *
  45.  *        Val()                     Count:    1                             *
  46.  *        mGetToken(FALSE)          Count:    3                             *
  47.  *        mSimpleExpression()       Count:    1                             *
  48.  *        mSyntaxError()            Count:    1                             *
  49.  *      END mFactor                                                         *
  50.  *                                                                          *
  51.  *      TOTALS FOR ALL BLOCKS:                                              *
  52.  *        AddLine()                 Count:    4                             *
  53.  *        Ask()                     Count:   17                             *
  54.  *        EmptyBuffer()             Count:    1                             *
  55.  *        EraseDiskFile()           Count:    1                             *
  56.  *        Return()                  Count:  103                             *
  57.  *        Val()                     Count:    8                             *
  58.  *        mGetToken(TRUE)           Count:    1                             *
  59.  *        mGetToken(FALSE)          Count:    5                             *
  60.  *        mSimpleExpression()       Count:    2                             *
  61.  *        mSyntaxError()            Count:    3                             *
  62.  *                                                                          *
  63.  *      END TOTALS           :         Total Call Count: 1780               *
  64.  *                                                                          *
  65.  *  CallList also includes the ability to incorporate map file information. *
  66.  *  IF CallList uses a map file (.MAP) for the SAL file being analyzed, it  *
  67.  *  will also INCLUDE code AND stack sizes in the listing.  To generate a   *
  68.  *  map file, specify the "-m" option WHEN compiling the file  with SC.     *
  69.  *  To determine whether to use a map file OR NOT, main(), below, must Set  *
  70.  *  "gCL_UseMapFile" to one of the following settings:                      *
  71.  *                                                                          *
  72.  *      SetGlobalInt("gCL_UseMapFile", 0) - DO NOT use a map file           *
  73.  *      SetGlobalInt("gCL_UseMapFile", 1) - DO use a map file               *
  74.  *      SetGlobalInt("gCL_UseMapFile", 2) - Ask whether to use a map file   *
  75.  *                                                                          *
  76.  *  IF a map file is used (either by setting "gCL_UseMapFile" to 1 OR by    *
  77.  *  setting it to 2 AND answering yes WHEN asked), CallList first looks for *
  78.  *  a map file with the same name as the current file, but with the .MAP    *
  79.  *  extension.  IF found, that map file is used.  IF it isn't found, the    *
  80.  *  user will be prompted to specify the map file to use.  For example, IF  *
  81.  *  the current file is "TEST.S", CallList would look for "TEST.MAP", AND   *
  82.  *  use it IF found.  IF "TEST.MAP" isn't found, CallList will prompt you   *
  83.  *  to specify the name of the map file to use.                             *
  84.  *                                                                          *
  85.  *  IF a map file is used, the listing will look similar to:                *
  86.  *                                                                          *
  87.  *      INTEGER PROC mFactor()                   Code:    68  Stack:     4  *
  88.  *        Return()                  Count:    1                             *
  89.  *        Val()                     Count:    1                             *
  90.  *        mGetToken(FALSE)          Count:    3  Code:   381  Stack:   261  *
  91.  *        mSimpleExpression()       Count:    1  Code:   145  Stack:     8  *
  92.  *        mSyntaxError()            Count:    1  Code:    32  Stack:     0  *
  93.  *      END mFactor                                                         *
  94.  *                                                                          *
  95.  *      TOTALS FOR ALL BLOCKS:                                              *
  96.  *        AddLine()                 Count:    4                             *
  97.  *        Ask()                     Count:   17                             *
  98.  *        EmptyBuffer()             Count:    1                             *
  99.  *        EraseDiskFile()           Count:    1                             *
  100.  *        Return()                  Count:  103                             *
  101.  *        Val()                     Count:    8                             *
  102.  *        mGetToken(TRUE)           Count:    1  Code:   381  Stack:   261  *
  103.  *        mGetToken(FALSE)          Count:    5  Code:   381  Stack:   261  *
  104.  *        mSimpleExpression()       Count:    2  Code:   145  Stack:     8  *
  105.  *        mSyntaxError()            Count:    3  Code:    32  Stack:     0  *
  106.  *                                                                          *
  107.  *      END TOTALS           :         Total Call Count: 1780               *
  108.  *                                                                          *
  109.  *  Use your imagination - such numbers should HELP to develop more         *
  110.  *  efficient SAL procedures.  For example, although mFactor above looks    *
  111.  *  like it needs 68 bytes for code AND 4 for the stack, it calls           *
  112.  *  another procedure, mGetToken, which requires 381 bytes for code AND     *
  113.  *  261 for the stack. That means mFactor actually needs 449 bytes for      *
  114.  *  code AND 265 for the stack - assuming mGetToken (OR the other called    *
  115.  *  procedures) does NOT call other procedures.                             *
  116.  *                                                                          *
  117.  *  IF you're running out of macro OR stack space, OR are just curious,     *
  118.  *  CallList might be helpful.                                              *
  119.  *                                                                          *
  120.  *  IF you have any questions, OR CallList doesn't work properly, please    *
  121.  *  leave me a Message.                                                     *
  122.  *                                                                          *
  123.  *  Ray Asbury                                                              *
  124.  *                                                                          *
  125.  *  Known Bugs: 02-15-93    ERA Reporting for calls which contain quoted    *
  126.  *                                  strings, is misleading, in that such    *
  127.  *                                  calls will appear in the report without *
  128.  *                                  the quoted strings.  Therefor, two      *
  129.  *                                  calls to the same proc/command, but     *
  130.  *                                  with different quoted strings, will be  *
  131.  *                                  reported together.                      *
  132.  *                                                                          *
  133.  *  Modifications:                                                          *
  134.  *                                                                          *
  135.  *      v2.0    01-22-93    ERA Added gCL_MapFileAltLoc to allow specifying *
  136.  *                                  an alternate location to search for MAP *
  137.  *                                  files                                   *
  138.  *                              Included proc/command arguments in calls,   *
  139.  *                                  provided the proc/command name and args *
  140.  *                                  does not exceed 37 characters in length *
  141.  *      v2.1    02-03-93    ERA Re-compiled for use with TSE .65ß           *
  142.  *      v2.2    02-15-93    ERA Fixed mismatching of calls with MAP file    *
  143.  *                                  data where the name of the called proc/ *
  144.  *                                  command was a subset of another which   *
  145.  *                                  was found in the MAP file.              *
  146.  *      v2.3    02-17-93    ERA Fixed MAP file conflict when proc has the   *
  147.  *                                  same name as the SAL file               *
  148.  *                              Included ability for user to set whether to *
  149.  *                                  consider case when sorting              *
  150.  *      v2.4    03-03-93    ERA Re-compiled for TSE .67ß                    *
  151.  *      v2.5    03-05-93    ERA Re-compiled for TSE .68ß                    *
  152.  *      v2.6    03-24-93    ERA Re-compiled for TSE .72ß                    *
  153.  *      v2.7    03-26-93    ERA Re-compiled for TSE .73ß                    *
  154.  *      v2.8    03-26-93    ERA Re-compiled for TSE 1.0                     *
  155.  ****************************************************************************/
  156.  
  157. CONSTANT kCL_IGNORE_CASE = 1,
  158.          kCL_DONT_IGNORE_CASE = 2
  159.  
  160. PROC Main()
  161.  
  162.     SetGlobalStr("gCL_WordSet", ChrSet("0-9A-Z_a-zÇ-Ñα-ε"))
  163.  
  164.         // MODIFY THE ABOVE LINE, IF NEEDED, AS NOTED ABOVE IN THE
  165.         // DOCUMENTATION
  166.  
  167.         // MAXIMUM LENGTH OF gCL_WordSet IS 256 CHARACTERS
  168.  
  169.     SetGlobalInt("gCL_UseMapFile", 1)
  170.  
  171.         // MODIFY THE ABOVE LINE TO DETERMINE WHETHER THE MAP FILE WILL BE
  172.         // USED, WHERE gCL_UseMapFile = 0 FOR NO MAP FILE USAGE,
  173.         //             gCL_UseMapFile = 1 FOR AUTOMATIC MAP FILE USAGE
  174.         //             gCL_UseMapFile = 2 Ask WHETHER TO USE A MAP FILE EVERY
  175.         //                                TIME CallList IS EXECUTED
  176.  
  177.     SetGlobalStr("gCL_MapFileAltLoc", "C:\")
  178.  
  179.         // MODIFY THE ABOVE LINE TO SPECIFY AN ALTERNATE LOCATION FOR MAP
  180.         // FILES.  CALLLIST LOOKS FIRST IN THE SAME DIRECTORY AS THE SAL FILE
  181.         // BEING, PROCESSED.  IF A MAP FILE ISN'T FOUND THERE, IT WILL THEN
  182.         // LOOK IN THE DIRECTORY SPECIFIED ABOVE.
  183.  
  184.         // MAXIMUM LENGTH OF gCL_MapFileAltLoc IS 68 CHARACTERS
  185.  
  186.     SetGlobalInt("gCL_SortSensitive", kCL_DONT_IGNORE_CASE)
  187.  
  188.         // MODIFY THE ABOVE LINE TO SPECIFY WHETHER SORTING SHOULD BE CASE
  189.         // SENSITIVE (kCL_DONT_IGNORE_CASE) OR NOT (kCL_IGNORE_CASE)
  190.  
  191.     ExecMacro("CALLLST2")
  192.     PurgeMacro("CALLLIST")
  193. END Main